<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>轮播图片</title>
</head>
<script>
    function inti() {
        window.setInterval("show()",1000);
    }
    var num=1;
    function show() {
        num++;
        var url=document.getElementById("image");
        console.log(num);
        url.src="img/"+num+".jpg";
        if(num===8){num=1;}

    }

</script>
<style>
    .container{
        width: 240px;
        height: 235px;
    }
</style>
<body onload="inti()">
  <div class="container">
      <img class="container" id="image" src="img/1.jpg">
  </div>
</body>
</html>